Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shutter position consts and logic for setting shutter pos #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OCopping
Copy link
Contributor

No description provided.

@OCopping OCopping requested a review from GDYendell March 17, 2023 10:32
Copy link
Contributor

@GDYendell GDYendell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine. I assume the reason for this is that the epics record expects an int, not the enum string? Could you add a note saying as much in the commit body? It isn't clear this change is practically any different without the context.

@@ -862,7 +862,9 @@ def _set_shutter_pos(self, val: float, shutter_state: str) -> None:
if shutter_state == SHUTTER_CLOSED:
self._configure_param({"shutter_closed_position": val})

current_shutter_state = "CLOSED" if self.shutter.get() == 0 else "OPEN"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GDYendell The reason I changed it to ints was because of this line. It would then pass a string into _set_shutter() which expects 0, otherwise the else is triggered. So pretty much it would always trigger the else clause as they were strings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. You haven't changed the conditional, it is still checking self.shutter.get() == 0, you have only changed the assignment to be an int rather than a string, which just changes the value passed to self._set_shutter (which does make sense to me, just the explanation does not).

current_shutter_state = "CLOSED" if self.shutter.get() == 0 else "OPEN"
current_shutter_state = (
SHUTTER_CLOSED if self.shutter.get() == 0 else SHUTTER_OPEN
)
if current_shutter_state == shutter_state:
self._set_shutter(shutter_state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this wrong? Shouldn't it only call set if the current value does not match the new value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So _set_shutter_pos() only updates the stored position value and doesn't actually move the shutter, _set_shutter() does. This line was added to make sure the shutter updated it's position if in the currently selected state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. if in the SHUTTER_CLOSED state, but the shutter_pos_closed is updated from 50 cts to 100 cts, it will then trigger the shutter to move to 100 cts

@garryod garryod requested a review from coretl July 15, 2024 12:59
@coretl coretl removed their request for review July 15, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants